<!doctype html>

<html>
<head>
  <link rel="shortcut icon" href="static/images/favicon.ico" type="image/x-icon">
  <title>platform_test.js (Closure Library API Documentation - JavaScript)</title>
  <link rel="stylesheet" href="static/css/base.css">
  <link rel="stylesheet" href="static/css/doc.css">
  <link rel="stylesheet" href="static/css/sidetree.css">
  <link rel="stylesheet" href="static/css/prettify.css">

  <script>
     var _staticFilePath = "static/";
     var _typeTreeName = "goog";
     var _fileTreeName = "Source";
  </script>

  <script src="static/js/doc.js">
  </script>


  <meta charset="utf8">
</head>

<body onload="grokdoc.onLoad();">

<div id="header">
  <div class="g-section g-tpl-50-50 g-split">
    <div class="g-unit g-first">
      <a id="logo" href="index.html">Closure Library API Documentation</a>
    </div>

    <div class="g-unit">
      <div class="g-c">
        <strong>Go to class or file:</strong>
        <input type="text" id="ac">
      </div>
    </div>
  </div>
</div>

<div class="clear"></div>

<h2><a href="local_closure_goog_labs_useragent_platform_test.js.html">platform_test.js</a></h2>

<pre class="prettyprint lang-js">
<a name="line1"></a>// Copyright 2013 The Closure Library Authors. All Rights Reserved.
<a name="line2"></a>//
<a name="line3"></a>// Licensed under the Apache License, Version 2.0 (the &quot;License&quot;);
<a name="line4"></a>// you may not use this file except in compliance with the License.
<a name="line5"></a>// You may obtain a copy of the License at
<a name="line6"></a>//
<a name="line7"></a>//      http://www.apache.org/licenses/LICENSE-2.0
<a name="line8"></a>//
<a name="line9"></a>// Unless required by applicable law or agreed to in writing, software
<a name="line10"></a>// distributed under the License is distributed on an &quot;AS-IS&quot; BASIS,
<a name="line11"></a>// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
<a name="line12"></a>// See the License for the specific language governing permissions and
<a name="line13"></a>// limitations under the License.
<a name="line14"></a>
<a name="line15"></a>/**
<a name="line16"></a> * @fileoverview Unit tests for goog.labs.userAgent.platform.
<a name="line17"></a> */
<a name="line18"></a>
<a name="line19"></a>goog.provide(&#39;goog.labs.userAgent.platformTest&#39;);
<a name="line20"></a>
<a name="line21"></a>goog.require(&#39;goog.labs.userAgent.platform&#39;);
<a name="line22"></a>goog.require(&#39;goog.labs.userAgent.testAgents&#39;);
<a name="line23"></a>goog.require(&#39;goog.labs.userAgent.util&#39;);
<a name="line24"></a>goog.require(&#39;goog.testing.jsunit&#39;);
<a name="line25"></a>
<a name="line26"></a>goog.setTestOnly(&#39;goog.labs.userAgent.platformTest&#39;);
<a name="line27"></a>
<a name="line28"></a>function setUp() {
<a name="line29"></a>  goog.labs.userAgent.util.setUserAgent(null);
<a name="line30"></a>}
<a name="line31"></a>
<a name="line32"></a>function testAndroid() {
<a name="line33"></a>  var uaString = goog.labs.userAgent.testAgents.ANDROID_BROWSER_233;
<a name="line34"></a>
<a name="line35"></a>  goog.labs.userAgent.util.setUserAgent(uaString);
<a name="line36"></a>  assertTrue(goog.labs.userAgent.platform.isAndroid());
<a name="line37"></a>  assertVersion(&#39;2.3.3&#39;);
<a name="line38"></a>  assertVersionBetween(&#39;2.3.0&#39;, &#39;2.3.5&#39;);
<a name="line39"></a>  assertVersionBetween(&#39;2.3&#39;, &#39;2.4&#39;);
<a name="line40"></a>  assertVersionBetween(&#39;2&#39;, &#39;3&#39;);
<a name="line41"></a>
<a name="line42"></a>  uaString = goog.labs.userAgent.testAgents.ANDROID_BROWSER_221;
<a name="line43"></a>
<a name="line44"></a>  goog.labs.userAgent.util.setUserAgent(uaString);
<a name="line45"></a>  assertTrue(goog.labs.userAgent.platform.isAndroid());
<a name="line46"></a>  assertVersion(&#39;2.2.1&#39;);
<a name="line47"></a>  assertVersionBetween(&#39;2.2.0&#39;, &#39;2.2.5&#39;);
<a name="line48"></a>  assertVersionBetween(&#39;2.2&#39;, &#39;2.3&#39;);
<a name="line49"></a>  assertVersionBetween(&#39;2&#39;, &#39;3&#39;);
<a name="line50"></a>
<a name="line51"></a>  uaString = goog.labs.userAgent.testAgents.CHROME_ANDROID;
<a name="line52"></a>
<a name="line53"></a>  goog.labs.userAgent.util.setUserAgent(uaString);
<a name="line54"></a>  assertTrue(goog.labs.userAgent.platform.isAndroid());
<a name="line55"></a>  assertVersion(&#39;4.0.2&#39;);
<a name="line56"></a>  assertVersionBetween(&#39;4.0.0&#39;, &#39;4.1.0&#39;);
<a name="line57"></a>  assertVersionBetween(&#39;4.0&#39;, &#39;4.1&#39;);
<a name="line58"></a>  assertVersionBetween(&#39;4&#39;, &#39;5&#39;);
<a name="line59"></a>}
<a name="line60"></a>
<a name="line61"></a>function testKindleFire() {
<a name="line62"></a>  uaString = goog.labs.userAgent.testAgents.KINDLE_FIRE;
<a name="line63"></a>  goog.labs.userAgent.util.setUserAgent(uaString);
<a name="line64"></a>  assertTrue(goog.labs.userAgent.platform.isAndroid());
<a name="line65"></a>  assertVersion(&#39;4.0.3&#39;);
<a name="line66"></a>}
<a name="line67"></a>
<a name="line68"></a>function testIpod() {
<a name="line69"></a>  var uaString = goog.labs.userAgent.testAgents.SAFARI_IPOD;
<a name="line70"></a>
<a name="line71"></a>  goog.labs.userAgent.util.setUserAgent(uaString);
<a name="line72"></a>  assertTrue(goog.labs.userAgent.platform.isIpod());
<a name="line73"></a>  assertTrue(goog.labs.userAgent.platform.isIos());
<a name="line74"></a>  assertVersion(&#39;&#39;);
<a name="line75"></a>}
<a name="line76"></a>
<a name="line77"></a>function testIphone() {
<a name="line78"></a>  var uaString = goog.labs.userAgent.testAgents.SAFARI_IPHONE_421;
<a name="line79"></a>  goog.labs.userAgent.util.setUserAgent(uaString);
<a name="line80"></a>  assertTrue(goog.labs.userAgent.platform.isIphone());
<a name="line81"></a>  assertTrue(goog.labs.userAgent.platform.isIos());
<a name="line82"></a>  assertVersion(&#39;4.2.1&#39;);
<a name="line83"></a>  assertVersionBetween(&#39;4&#39;, &#39;5&#39;);
<a name="line84"></a>  assertVersionBetween(&#39;4.2&#39;, &#39;4.3&#39;);
<a name="line85"></a>
<a name="line86"></a>  uaString = goog.labs.userAgent.testAgents.SAFARI_IPHONE_6;
<a name="line87"></a>  goog.labs.userAgent.util.setUserAgent(uaString);
<a name="line88"></a>  assertTrue(goog.labs.userAgent.platform.isIphone());
<a name="line89"></a>  assertTrue(goog.labs.userAgent.platform.isIos());
<a name="line90"></a>  assertVersion(&#39;6.0&#39;);
<a name="line91"></a>  assertVersionBetween(&#39;5&#39;, &#39;7&#39;);
<a name="line92"></a>
<a name="line93"></a>  uaString = goog.labs.userAgent.testAgents.SAFARI_IPHONE_32;
<a name="line94"></a>  goog.labs.userAgent.util.setUserAgent(uaString);
<a name="line95"></a>  assertTrue(goog.labs.userAgent.platform.isIphone());
<a name="line96"></a>  assertTrue(goog.labs.userAgent.platform.isIos());
<a name="line97"></a>  assertVersion(&#39;3.2&#39;);
<a name="line98"></a>  assertVersionBetween(&#39;3&#39;, &#39;4&#39;);
<a name="line99"></a>}
<a name="line100"></a>
<a name="line101"></a>function testIpad() {
<a name="line102"></a>  var uaString = goog.labs.userAgent.testAgents.IPAD_4;
<a name="line103"></a>
<a name="line104"></a>  goog.labs.userAgent.util.setUserAgent(uaString);
<a name="line105"></a>  assertTrue(goog.labs.userAgent.platform.isIpad());
<a name="line106"></a>  assertTrue(goog.labs.userAgent.platform.isIos());
<a name="line107"></a>  assertVersion(&#39;3.2&#39;);
<a name="line108"></a>  assertVersionBetween(&#39;3&#39;, &#39;4&#39;);
<a name="line109"></a>  assertVersionBetween(&#39;3.1&#39;, &#39;4&#39;);
<a name="line110"></a>
<a name="line111"></a>  uaString = goog.labs.userAgent.testAgents.IPAD_5;
<a name="line112"></a>
<a name="line113"></a>  goog.labs.userAgent.util.setUserAgent(uaString);
<a name="line114"></a>  assertTrue(goog.labs.userAgent.platform.isIpad());
<a name="line115"></a>  assertTrue(goog.labs.userAgent.platform.isIos());
<a name="line116"></a>  assertVersion(&#39;5.1&#39;);
<a name="line117"></a>  assertVersionBetween(&#39;5&#39;, &#39;6&#39;);
<a name="line118"></a>
<a name="line119"></a>  uaString = goog.labs.userAgent.testAgents.IPAD_6;
<a name="line120"></a>
<a name="line121"></a>  goog.labs.userAgent.util.setUserAgent(uaString);
<a name="line122"></a>  assertTrue(goog.labs.userAgent.platform.isIpad());
<a name="line123"></a>  assertTrue(goog.labs.userAgent.platform.isIos());
<a name="line124"></a>  assertVersion(&#39;6.0&#39;);
<a name="line125"></a>  assertVersionBetween(&#39;5&#39;, &#39;7&#39;);
<a name="line126"></a>}
<a name="line127"></a>
<a name="line128"></a>function testMac() {
<a name="line129"></a>  var uaString = goog.labs.userAgent.testAgents.CHROME_MAC;
<a name="line130"></a>  var platform = &#39;IntelMac&#39;;
<a name="line131"></a>  goog.labs.userAgent.util.setUserAgent(uaString, platform);
<a name="line132"></a>  assertTrue(goog.labs.userAgent.platform.isMacintosh());
<a name="line133"></a>  assertVersion(&#39;10.8.2&#39;);
<a name="line134"></a>  assertVersionBetween(&#39;10&#39;, &#39;11&#39;);
<a name="line135"></a>  assertVersionBetween(&#39;10.8&#39;, &#39;10.9&#39;);
<a name="line136"></a>  assertVersionBetween(&#39;10.8.1&#39;, &#39;10.8.3&#39;);
<a name="line137"></a>
<a name="line138"></a>  uaString = goog.labs.userAgent.testAgents.OPERA_MAC;
<a name="line139"></a>  goog.labs.userAgent.util.setUserAgent(uaString, platform);
<a name="line140"></a>  assertTrue(goog.labs.userAgent.platform.isMacintosh());
<a name="line141"></a>  assertVersion(&#39;10.6.8&#39;);
<a name="line142"></a>  assertVersionBetween(&#39;10&#39;, &#39;11&#39;);
<a name="line143"></a>  assertVersionBetween(&#39;10.6&#39;, &#39;10.7&#39;);
<a name="line144"></a>  assertVersionBetween(&#39;10.6.5&#39;, &#39;10.7.0&#39;);
<a name="line145"></a>
<a name="line146"></a>  uaString = goog.labs.userAgent.testAgents.SAFARI_MAC;
<a name="line147"></a>  goog.labs.userAgent.util.setUserAgent(uaString, platform);
<a name="line148"></a>  assertTrue(goog.labs.userAgent.platform.isMacintosh());
<a name="line149"></a>  assertVersionBetween(&#39;10&#39;, &#39;11&#39;);
<a name="line150"></a>  assertVersionBetween(&#39;10.6&#39;, &#39;10.7&#39;);
<a name="line151"></a>  assertVersionBetween(&#39;10.6.5&#39;, &#39;10.7.0&#39;);
<a name="line152"></a>
<a name="line153"></a>  uaString = goog.labs.userAgent.testAgents.FIREFOX_MAC;
<a name="line154"></a>  goog.labs.userAgent.util.setUserAgent(uaString, platform);
<a name="line155"></a>  assertTrue(goog.labs.userAgent.platform.isMacintosh());
<a name="line156"></a>  assertVersion(&#39;11.7.9&#39;);
<a name="line157"></a>  assertVersionBetween(&#39;11&#39;, &#39;12&#39;);
<a name="line158"></a>  assertVersionBetween(&#39;11.7&#39;, &#39;11.8&#39;);
<a name="line159"></a>  assertVersionBetween(&#39;11.7.9&#39;, &#39;11.8.0&#39;);
<a name="line160"></a>}
<a name="line161"></a>
<a name="line162"></a>function testLinux() {
<a name="line163"></a>  var uaString = goog.labs.userAgent.testAgents.FIREFOX_LINUX;
<a name="line164"></a>  goog.labs.userAgent.util.setUserAgent(uaString);
<a name="line165"></a>  assertTrue(goog.labs.userAgent.platform.isLinux());
<a name="line166"></a>  assertVersion(&#39;&#39;);
<a name="line167"></a>
<a name="line168"></a>  uaString = goog.labs.userAgent.testAgents.CHROME_LINUX;
<a name="line169"></a>  goog.labs.userAgent.util.setUserAgent(uaString);
<a name="line170"></a>  assertTrue(goog.labs.userAgent.platform.isLinux());
<a name="line171"></a>  assertVersion(&#39;&#39;);
<a name="line172"></a>
<a name="line173"></a>  uaString = goog.labs.userAgent.testAgents.OPERA_LINUX;
<a name="line174"></a>  goog.labs.userAgent.util.setUserAgent(uaString);
<a name="line175"></a>  assertTrue(goog.labs.userAgent.platform.isLinux());
<a name="line176"></a>  assertVersion(&#39;&#39;);
<a name="line177"></a>}
<a name="line178"></a>
<a name="line179"></a>function testWindows() {
<a name="line180"></a>  var uaString = goog.labs.userAgent.testAgents.SAFARI_WINDOWS;
<a name="line181"></a>  goog.labs.userAgent.util.setUserAgent(uaString);
<a name="line182"></a>  assertTrue(goog.labs.userAgent.platform.isWindows());
<a name="line183"></a>  assertVersion(&#39;6.1&#39;);
<a name="line184"></a>  assertVersionBetween(&#39;6&#39;, &#39;7&#39;);
<a name="line185"></a>
<a name="line186"></a>  uaString = goog.labs.userAgent.testAgents.IE_10;
<a name="line187"></a>  goog.labs.userAgent.util.setUserAgent(uaString);
<a name="line188"></a>  assertTrue(goog.labs.userAgent.platform.isWindows());
<a name="line189"></a>  assertVersion(&#39;6.2&#39;);
<a name="line190"></a>  assertVersionBetween(&#39;6&#39;, &#39;6.5&#39;);
<a name="line191"></a>
<a name="line192"></a>  uaString = goog.labs.userAgent.testAgents.CHROME_25;
<a name="line193"></a>  goog.labs.userAgent.util.setUserAgent(uaString);
<a name="line194"></a>  assertTrue(goog.labs.userAgent.platform.isWindows());
<a name="line195"></a>  assertVersion(&#39;5.1&#39;);
<a name="line196"></a>  assertVersionBetween(&#39;5&#39;, &#39;6&#39;);
<a name="line197"></a>
<a name="line198"></a>  uaString = goog.labs.userAgent.testAgents.FIREFOX_WINDOWS;
<a name="line199"></a>  goog.labs.userAgent.util.setUserAgent(uaString);
<a name="line200"></a>  assertTrue(goog.labs.userAgent.platform.isWindows());
<a name="line201"></a>  assertVersion(&#39;6.1&#39;);
<a name="line202"></a>  assertVersionBetween(&#39;6&#39;, &#39;7&#39;);
<a name="line203"></a>
<a name="line204"></a>  uaString = goog.labs.userAgent.testAgents.IE_11;
<a name="line205"></a>  goog.labs.userAgent.util.setUserAgent(uaString);
<a name="line206"></a>  assertTrue(goog.labs.userAgent.platform.isWindows());
<a name="line207"></a>  assertVersion(&#39;6.3&#39;);
<a name="line208"></a>  assertVersionBetween(&#39;6&#39;, &#39;6.5&#39;);
<a name="line209"></a>}
<a name="line210"></a>
<a name="line211"></a>function testChromeOS() {
<a name="line212"></a>  var uaString = goog.labs.userAgent.testAgents.CHROME_OS_910;
<a name="line213"></a>
<a name="line214"></a>  goog.labs.userAgent.util.setUserAgent(uaString);
<a name="line215"></a>  assertTrue(goog.labs.userAgent.platform.isChromeOS());
<a name="line216"></a>  assertVersion(&#39;9.10.0&#39;);
<a name="line217"></a>  assertVersionBetween(&#39;9&#39;, &#39;10&#39;);
<a name="line218"></a>
<a name="line219"></a>  uaString = goog.labs.userAgent.testAgents.CHROME_OS;
<a name="line220"></a>
<a name="line221"></a>  goog.labs.userAgent.util.setUserAgent(uaString);
<a name="line222"></a>  assertTrue(goog.labs.userAgent.platform.isChromeOS());
<a name="line223"></a>  assertVersion(&#39;3701.62.0&#39;);
<a name="line224"></a>  assertVersionBetween(&#39;3701&#39;, &#39;3702&#39;);
<a name="line225"></a>}
<a name="line226"></a>
<a name="line227"></a>function assertVersion(version) {
<a name="line228"></a>  assertEquals(version, goog.labs.userAgent.platform.getVersion());
<a name="line229"></a>}
<a name="line230"></a>
<a name="line231"></a>function assertVersionBetween(lowVersion, highVersion) {
<a name="line232"></a>  assertTrue(goog.labs.userAgent.platform.isVersionOrHigher(lowVersion));
<a name="line233"></a>  assertFalse(goog.labs.userAgent.platform.isVersionOrHigher(highVersion));
<a name="line234"></a>}
</pre>


</body>
</html>
